<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>用户登录</title>
	<jsp:include page="common/_js.jsp"></jsp:include>
	<style>
	.ui-autocomplete-loading { background: url('images/ui-anim_basic_16x16.gif') 340px 5px no-repeat; }
	</style>
	<script type="text/javascript">
	$(document).ready(function() {
		$(".logina").click(function(){
			$(this).parents(".btn-toolbar").addClass("ui-autocomplete-loading");
			
			var obj = new Object();
			
			obj["role"] = $(this).attr("href");
			
			$(":text").each(function(){
				obj[this.name] = $(this).val();
			});
			
			$(":password").each(function(){
				obj[this.name] = $(this).val();
			});
			
			$(":radio:checked").each(function(){
				obj[this.name] = $(this).val();
			});

			$.getJSON("com/userAction!login.jspa", obj, function(json) {
				switch (json.state) {
					case "checkCode":{
						alert("验证码错误");
						window.location.reload();
						break;
					}
					case "checkPsw" :{
						alert("用户不存在或密码错误");
						window.location.reload();
						break;
					}
					case "checkRole":{
						alert("没有权限登录");
						window.location.reload();
						break;
					}
					default:{
						window.location.assign($("base").attr("href")+"com/"+json.state+"/index.jsp" );
						break;
					}
				}
			});
			
			return false;
		});
	});
	</script>
</head>
<body>
	<div id="web">
		<div style="width: 650px;margin: 0 auto;">
			<div><img alt="" src="images/logo.png"></div>
				<div class="well" style="margin-top: 30px;padding: 8px 0;">
				<ul class="nav nav-list">
         			<li class="active"><a href="#" style="font-size: 20px;line-height: 25px;font-weight:bolder;"><i class="icon-home icon-white"></i> 用户登录</a></li>
       			</ul>
				
				<s:form action="userAction!login.jspa" namespace="/com" cssClass="validate">
					<div class="field control-group">
						<label class="" for="userAction_username">用户名</label>
						<input id="userAction_username" type="text" name="username" class="required alphanum">
					</div>
					<div class="field control-group">
						<label class="" for="userAction_password">密码</label>
						<input id="userAction_password" type="password" name="password" class="required alphanum">
					</div>
					<div class="field control-group">
						<label  class="" for="userAction_code">验证码</label>
						<input id="userAction_code" type="text"  name="code"  class="required alphanum">
						
					</div>
					
					<div style="padding-left: 100px" class="btn-toolbar">
					 	<div class="btn-group">
	      		 			<img alt="验证码" src="common/validateCodeAction!execute.jspa" class="vcimg" style="margin-bottom: 20px;">
	      				</div>
				        <div class="btn-group">
				          <a href="#" data-toggle="dropdown" class="btn btn-primary"><i class="icon-user icon-white"></i> 用户登录</a>
				          <a href="#" data-toggle="dropdown" class="btn btn-primary dropdown-toggle"><span class="caret"></span></a>
				          <ul class="dropdown-menu">
				            <li><a href="3" class="logina"><i class="icon-flag"></i> 导游</a></li>
				            <li><a href="5" class="logina"><i class="icon-th"></i> 内勤</a></li>
				            <li><a href="7" class="logina"><i class="icon-lock"></i> 总经理</a></li>
				            <li class="divider"></li>
				            <li><a href="9" class="logina"><i class="icon-cog"></i> 系统管理</a></li>
				          </ul>
				        </div>
	      			</div>
					
				</s:form>
				
				</div>
			<a href="http://localhost:8090/web/jQueryUIDev/demos/index.html" target="_blank">jQury-ui</a><br>
			<a href="http://localhost:8090/web/bootstrap/docs/index.html" target="_blank">bootstrap</a>
			<a href="javascript:void(function(d,%20w,%20g,%20s){w[g]&&typeof%20w[g].showMenu=='function'?w[g].showMenu():(s%20=%20d.createElement('script'),%20s.charset='utf-8',%20s.src='http://localhost:8090/web/js/youdao.js?'+Math.floor(+new%20Date/8.64E7),%20d.body.appendChild(s));}(document,%20window,%20'__GLY'));">书签工具</a>
		</div>
	</div>
  
</body>
</html>

